# This file is part of The Vu Toolkit.
#
# The Vu Toolkit is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3.0 of the License, or (at your option) any later version.
#
# The Vu Toolkit is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with The Vu Toolkit; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA.
#
# Copyright © Zak Fenton 2008
#

# A mixin implementing view boxes
module Vu::SVG::ViewBox
	# Applies the view box's transformation to the Cairo context. This method
	# depends on x, y, width and height being defined on the element.
	#
	# FIXME: This isn't a real implementation. Only takes width/height into account!
	def apply_view_box_to_cairo (cr)
		if @view_box
			#tr_x = view_box.x - x
			#tr_y = view_box.y - y
			sc_x = width.to_f/view_box.width
			sc_y = height.to_f/view_box.height
			cr.scale(sc_x,sc_y)
		end
	end

	# Sets the element's view box to given Bounds
	def view_box= (b)
		@view_box = b
	end
	
	# Gets the view box
	def view_box
		@view_box
	end
end

